package com.hb.core.pojo.flow.entity;

import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.RandomUtil;
import com.baomidou.mybatisplus.annotation.TableName;
import com.hb.core.pojo.parent.MPCommonEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * <p>
 * 流程主表
 * </p>
 *
 * @author zhaojk
 * @since 2021-05-27
 */
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("work_flow_main")
@ApiModel(value = "FlowMain对象", description = "流程主表")
public class FlowMain extends MPCommonEntity {

    @ApiModelProperty(value = "流程发起人ID")
    private Long userId;

    @ApiModelProperty(value = "流程模板ID")
    private Long tempMainId;

    @ApiModelProperty(value = "流程号(生成规则: yyyyMMdd + random(3))")
    private String flowNum;

    @ApiModelProperty(value = "当前审批节点")
    private Long currentNodeId;

    @ApiModelProperty(value = "当前审批节点索引")
    private Integer currentNodeIndex;

    @ApiModelProperty(value = "当前流程状态(1: 审批中, 2: 流程终止 - 审批通过, 3: 流程终止 - 审批驳回, 4: 挂起 - 加签人审批中)")
    private Integer flowStatus;

    @ApiModelProperty(value = "乐观锁标识")
    private Integer version;

    public void getRandomFlowNum() {
        String dateFlag = DateUtil.today().replace("-", "");
        int numberFlag = RandomUtil.randomInt(100, 1000);
        this.setFlowNum(dateFlag + numberFlag);
    }

}
